﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Database.Models
{
    [Table("NguonNuoc")]
    public class NguonNuoc:BaseModel
    {
        public int Id { get; set; }

        [Required]
        [MaxLength(255)]
        public string Ten { get; set; }

        [MaxLength(255)]
        public string TrongCoSo { get; set; }

        [MaxLength(255)]
        public string NgoaiCoSo { get; set; }

        [MaxLength(255)]
        public string KhoiTich { get; set; }

        [MaxLength(255)]
        public string XeCC { get; set; }

        [MaxLength(255)]
        public string MBCC { get; set; }
        
        public virtual PhanLoaiChiTietNguonNuoc PhanLoaiChiTietNguonNuoc { get; set; }
        public virtual PhieuDieuTraCoSo PhieuDieuTraCoSoes { get; set; }

        [NotMapped]
        public string TenPhanLoaiChiTietNguonNuoc
        {
            get
            {
                if (PhanLoaiChiTietNguonNuoc != null)
                {
                    return PhanLoaiChiTietNguonNuoc.Ten;
                }
                return string.Empty;
            }
        }

        [NotMapped]
        public string TenLoaiNguonNuoc
        {
            get
            {
                if (PhanLoaiChiTietNguonNuoc.LoaiNguonNuoc != null)
                {
                    return PhanLoaiChiTietNguonNuoc.LoaiNguonNuoc.Ten;
                }
                return string.Empty;
            }
        }
    }
}
